package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 苏李涛
 * Date: 2024-10-09
 * Time: 23:36
 */

class MyThread extends Thread {
    @Override
    public void run() {

        while (true) {

            System.out.println("这⾥是t线程运⾏的代码");

            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

public class Demo1 {
    public static void main(String[] args) throws InterruptedException {
        MyThread t = new MyThread();

        t.start();

        while (true) {
            System.out.println("这里是主线程");
            Thread.sleep(1000);
        }
    }
}
